package com.iot.server.service.impl;

import com.iot.core.exception.BDException;
import com.iot.server.dao.SysUserDOMapper;
import com.iot.server.domain.SysUserDO;
import com.iot.server.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wuzt
 * Date 2020/6/23 9:34
 * Version 1.0
 * @ClassName UserServiceImpl
 * Description
 **/
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    SysUserDOMapper sysUserDOMapper;

    @Override
    public SysUserDO findByUserName(String username) {
        if (StringUtils.isEmpty(username)) {
            throw new BDException("用户名不能为空");
        }
        SysUserDO entity = new SysUserDO();
        entity.setUserAccount(username);
        return sysUserDOMapper.selectByEntity(entity);
    }

    @Override
    public SysUserDO selectUserById(String userId) {
        if (StringUtils.isEmpty(userId)) {
            throw new BDException("用户id不能为空");
        }
        return sysUserDOMapper.selectByPrimaryKey(userId);
    }
}
